﻿using UnityEngine;
using UnityEngine.UI;
using Framework.Util;

namespace Framework.UI
{
    public class ExToggle : Toggle
    {
        public enum EnumCallbackType
        {
            /// <summary>数值改变</summary>
            ValueChange,
        }

        private GameObject mOnGameObject = null;
        private GameObject mOffGameObject = null;

        protected override void Awake()
        {
            base.Awake();

            mOnGameObject = UtilCollection.GameObjectUtil.FindOrCraeteChild(gameObject, "On");
            mOffGameObject = UtilCollection.GameObjectUtil.FindOrCraeteChild(gameObject, "Off");
            onValueChanged.AddListener(OnValueChange);
        }

        private void OnValueChange(bool pValue)
        {
            mOnGameObject?.SetActive(pValue);
            mOffGameObject?.SetActive(!pValue);
        }
    }
}